﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Mytrip.Users.mytrip_Users>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	All users
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2 style="position: relative; float: right"><%= Html.ActionLink("All roles", "IndexRole", new { id = 1, id2 = 10, id3 = "RoleName" })%></h2>
    <h2>All users</h2>
        
   
    <%=Html.MytripPager(10, (int)ViewData["total"],"...")%>
    <table style="width: 100%;">
    <tr>
   <th style="text-align: right">
   <% using (Html.BeginForm())
   { %> <%= Html.TextBox("search")%>
    <input type="submit" value="Search user" />
<%} %></th></tr></table>
    <table style="width: 100%;">    
        <tr>
            <th style="width: 50px;"></th>
            <th>
                <%= Html.ActionLink("User Name", "Index", new { id = 1, id2 = 10, id3 = Html.MytripSort("UserName") })%>
            </th>
            <th>
                <%= Html.ActionLink("Email", "Index", new { id = 1, id2 = 10, id3 = Html.MytripSort("Email") })%>
            </th>
            <th>
                <%= Html.ActionLink("Last Activity Date", "Index", new { id = 1, id2 = 10, id3 = Html.MytripSort("LastActivityDate") })%>
            </th>
            <th>
                <%= Html.ActionLink("Creation Date", "Index", new { id = 1, id2 = 10, id3 = Html.MytripSort("CreationDate") })%>
            </th>
            <th>
                <%= Html.ActionLink("Last Login Date", "Index", new { id = 1, id2 = 10, id3 = Html.MytripSort("LastLoginDate") })%>
            </th>
            <th>
                <%= Html.ActionLink("Last Password Changed Date", "Index", new { id = 1, id2 = 10, id3 = Html.MytripSort("LastPasswordChangedDate") })%>
            </th>
            <th>
                <%= Html.ActionLink("User IP", "Index", new { id = 1, id2 = 10, id3 = Html.MytripSort("UserIP") })%>
            </th>
            <th>
                IsApproved
            </th>
        </tr>
    <% foreach (var item in Model) { %>    
        <tr>
            <td><a href="<%=Url.Action("Details", new { id=item.UserName })%>">
                                <img src="/content/images/Users.png" alt="Details" style="border-width: 0px; width: 20px;" /></a>
                            <a href="<%=Url.Action("Delete", new {  id =item.UserName })%>" onclick="return confirm ('Are you sure?');">
                                <img src="/content/images/delete.png" alt="Delete" style="border-width: 0px; width: 20px;" /></a>
            </td>
            <td>
                <b><%= Html.Encode(item.UserName) %></b>
                <%int rolecount = item.mytrip_Roles.Count();
                  if (rolecount > 0)
                  { %><br />role: 
                  <% int _rolecount = 0;
                  foreach (Mytrip.Users.mytrip_Roles _item in item.mytrip_Roles.ToList())
                  {  %><%=_item.RoleName%><%_rolecount++;
                    if (_rolecount == rolecount) {%>.<% } else {%>, <% } %> 
                <%}
                  } %>
            </td>
            <td>
                <%= Html.Encode(item.mytrip_Membership.Email) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:d}", item.LastActivityDate)) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:d}", item.mytrip_Membership.CreationDate)) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:d}", item.mytrip_Membership.LastLoginDate)) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:d}", item.mytrip_Membership.LastPasswordChangedDate)) %>
            </td>
            <td>
               <%= Html.Encode(item.mytrip_Membership.UserIP) %>
            </td>
            <td>
                <%= Html.CheckBox("IsApproved", item.mytrip_Membership.IsApproved, new { disabled="true"})%>
            </td>
        </tr>    
    <% } %>
    </table>
    <%=Html.MytripPager(10, (int)ViewData["total"],"...")%>
    
</asp:Content>

